﻿using PC.PickleJar.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PC.PickleJar
{
	public class TestMethodValidationResult
	{
		public static readonly TestMethodValidationResult SuccessfulResult;

		static TestMethodValidationResult()
		{
			TestMethodValidationResult.SuccessfulResult =
				new TestMethodValidationResult()
				{
					Action = ResultActionEnum.RunTest,
					Message = String.Empty,
					Result = ResultEnum.Success
				};
		}

		private TestMethodValidationResult()
		{
		}

		internal TestMethodValidationResult(ResultEnum result, String message, ConfigurationHelper configHelper)
		{
			this.Result = result;
			this.Message = message ?? String.Empty;

			if (this.Result == ResultEnum.Failure)
			{
				switch (configHelper.ValidationFailureAction)
				{
					case Configuration.ValidationFailureActionsEnum.FailTest:
						this.Action = ResultActionEnum.FailTest;
						break;

					case Configuration.ValidationFailureActionsEnum.SkipTest:
						this.Action = ResultActionEnum.SkipTest;
						break;

					default:
						throw new NotImplementedException();
				}
			}
			else
			{
				this.Action = ResultActionEnum.RunTest;
			}
		}

		public ResultEnum Result
		{
			get;
			private set;
		}

		public ResultActionEnum Action
		{
			get;
			private set;
		}

		public string Message
		{
			get;
			private set;
		}
	}
}
